<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$nickname=pdo_getcolumn('core_members',array('id'=>$_SESSION['uid']),'nickname');
$return['nickname']=$nickname;
if($_RQ['op']=='main'){
            $clist   = pdo_getall('jy_jdpm_goods_group',array('uniacid'=>$_SESSION['uniacid'],'pid' => 0),'','','paixu asc');
            foreach ($clist as $clk => $clv) {
                $clist[$clk]['children'] =  pdo_getall('jy_jdpm_goods_group',array('uniacid'=>$_SESSION['uniacid'],'pid' => $clv['id']));
                foreach ($clist[$clk]['children'] as $clck => $clcv) {
                    $clist[$clk]['children'][$clck]['children'] = pdo_getall('jy_jdpm_goods_group',array('uniacid'=>$_SESSION['uniacid'],'pid' => $clcv['id']));
                }
                // 实力商家的获取【实力商家为该频道下商品成交数量最多的用户集合
                // 获取该频道下的子类cid
                $cate    = pdo_getall('jy_jdpm_goods_group',array('uniacid'=>$_SESSION['uniacid'],'pid' => $clv['cid']),'','','paixu desc');
                $gCidarr = getChildsId($cate, $clv['id']);
                //加入频道cid
                array_unshift($gCidarr , $clv['cid']);
                // 查询成交拍品的merchid集合
                $selUidarr1 =  pdo_getall('jy_weishop_goods',array('uniacid'=>$_SESSION['uniacid'],'id' => $gCidarr),'merchid');
				$selUidarr1 = $selUidarr1 ? $selUidarr1 : array();
				foreach ($selUidarr1 as $sk => $sv) {
                    $selUidarr[$sk] = $sv['merchid'];
                }
                // 统计每个用户的成交数量;[此函数为统计某值在数组中的数量]
				$selUidarr=$selUidarr?$selUidarr:array(0);
                $arsortSuid = array_count_values($selUidarr);
				
                // 根据成交数量从多到少排序用户merchid,[此函数为根据值对数组进行排序，不改变键值]
                arsort($arsortSuid);
                // 去除重复
                $selUidarr = array_flip(array_flip($selUidarr));
                // 获取20个实力商家
				
				$pindex = max(1, intval($_RQ['page']));
                $seller = pdo_getslice('jy_jdpm_member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$selUidarr),array($pindex,20),$total,array('mid','organization'),'');
                // 给商家进行排序
                foreach ($seller as $sk => $sv) {
                    $seller[$sk]['count'] = $arsortSuid[$sv['mid']];
                }
                // 按照降序根据成交拍品数量排序商家
                paixu($seller ,'count');
                // 获取频道内20个实例商家的信息
                $clist[$clk]['strength'] = $seller;
                // 实力商家的获取】
            }
        // 全部分类和实例商家的获取】
    $_SESSION['clist'] = $clist;
	$return['recommend']=$return['children']=pdo_getall('jy_jdpm_goods_group',array('uniacid'=>$_SESSION['uniacid'],'hot' => 1,'pid <>'=>0),'','','paixu desc');
	$return['clist']=$clist?$clist:array();
	set_html('title','分类-'.$this->plugin_setting('basic')['title']);
	exi($return);
}
?>